package org.sgx.gwtjsutiltest.client.appstate;

import org.sgx.gwtjsutiltest.client.appstate.states.Intro;
import org.sgx.gwtjsutiltest.client.appstate.states.Search;
import org.sgx.jsutil.client.appstate.AbstractAppStateManager;
import org.sgx.jsutil.client.appstate.AppState;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.BodyElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.ui.UIObject;

public class AppStateTest1EP implements EntryPoint {

	@Override
	public void onModuleLoad() {
		AbstractAppStateManager stateManager = new AbstractAppStateManager(){
			@Override
			public AppState getDefaultState() {
				return this.getStates().get("intro"); 
			}
		};

		Document doc = Document.get();
		BodyElement containerEl = doc.getBody();
				
		stateManager.addState(new MyAppState(containerEl, "intro") {			
			@Override
			protected UIObject buildNewView() {				
				return new Intro();
			}
		}); 
		stateManager.addState(new MyAppState(containerEl, "search") {			
			@Override
			protected UIObject buildNewView() {
				return new Search(); 
			}
		});
		
		stateManager.navigate(stateManager.getStates().get("intro"), "param1:val1"); 
		
	}

}
